#include<bits/stdc++.h>
using namespace std;

string zh(string a) {
	if(a.find(".") == -1) {
		a = a + ".";
	} 
	for(int i = 1; i <= 7; i ++ ) {
		a = a + "0";
	}
	return a;
}

int main() {
	string a, b;
	cin >> a >> b;
	a = zh(a);
	b = zh(b);
	int len = min(a.size(), b.size());
	
	bool flag = false;
	int gs = 0;
	for(int i = 0; i < len; i ++ ) {
		if(a[i] != b[i] ) {
			cout << "NO" << endl;
			return 0;
		}
		if(a[i] == '.') {
			if(b[i] != '.') {
				cout << "NO" << endl;
				return 0;
			}
			flag = true;
			continue;
		}
		if(flag == true && a[i] == b[i] ) {
			gs ++;
			if(gs == 6) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	return 0;
}

